<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="/fuman/js/purchase.js" ></script>
<script language="javascript" src="/fuman/js/TableFreeze.js"></script>
<script language="javascript">
	//修改增幅率
	function doRecommend(flag) {
		var str = selectallpro();
		if(str !=false)
		{
			if(flag==0){
				$('#dorecommendform').show();
			}
			if(flag==1){
				var set_rate = $("#updrate").val();
				var ppid_arr = document.getElementsByName("ppid[]");
				var hid_arr = document.getElementsByName("hid[]");
				for(var j = 0; j < ppid_arr.length; j++){
					if(ppid_arr[j].checked == true){
						$("#rate"+ppid_arr[j].value).val(set_rate);
						var calval = hid_arr[j].value;
						var arr_calc = calval.split(",");

						var cur_value = arr_calc[0]*0.8+arr_calc[1]*0.2+(arr_calc[0]*0.8+arr_calc[1]*0.2)*set_rate-arr_calc[2]-arr_calc[3]+arr_calc[4];
						var cur_value = Math.floor(cur_value);
						$("#nst"+ppid_arr[j].value).val(cur_value);

					}
				}
				$('#dorecommendform').hide();
			}

		}
	}
</script>
<title>添加工厂采购单</title>
<body class="withvernav">
<div class="bodywrapper">
	{{include file='/public/orderleft.tpl'}}
	<div class="centercontent">
		<div class="pageheader notab">
			<h1 class="pagetitle">添加工厂采购单</h1>
    <span class="pagedesc">
    1、停产  清仓  暂停销售 状态下的SKU不显示<br>
	    <!--
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2、采购数 = 半年内销量*0.8+去年同期销量*0.2 + (半年内销量*0.8+去年同期销量*0.2)*(±增幅率) - 在途 - 在库 +待发货<br>
    -->
	<!--
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2、默认显示厂1、厂2五位关联SKU（不包含８位定制），满足半年内销量大于等于50件的所有SKU列表<br>
    -->
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <br>
    </span>
		</div>
		<!--pageheader-->
		<div id="contentwrapper" class="contentwrapper">
			<div id="basicform" class="subcontent">
				<div style="float:left">
					&nbsp;&nbsp;&nbsp;
					<!--
					<button class="stdbtn btn_lime" onClick="doRecommend(0);return false;">修改增幅率</button>
					-->
					&nbsp;&nbsp;&nbsp; </div>
				<!--搜索栏-->
				<div class="page">{{$pageList}} 计{{$total}}条记录<!--，共{{$totalpage}}页--></div>
				<div style="clear: both"></div>
			</div>
			<form class="stdform stdform2" method="get" id="search" action="/purchase/addFactoryOrder">
				<div class="tableoptions">

					<select name="filtertype">
						<option value="">-查询条件-</option>
						<option value="productname" {{if $filtertype=='productname'}} selected{{/if}}>商品名称</option>
						<option value="productid" {{if $filtertype=='productid'}} selected{{/if}}>商品编号</option>
						<option value="positions"  {{if $filtertype=='positions'}} selected{{/if}}>库位</option>
					</select>
					:
					<input type="text" name="kw" id="kw" class="width200" value="{{$kw}}" placeholder="关键词" />
					<select name="supplier" id="supplier" class="selection" onChange="getsupplier()" >
						<option value="">供货商</option>
						{{foreach from=$factory item=res key=key}}
						<option value="{{$res.id}}" {{if $res.id == $supplier}} selected{{/if}}>{{$res.name}}</option>
						{{/foreach}}
					</select>
					&nbsp;
					版型:
					<select name="versiontype" id="versiontype" class="selection select2_group" style="width:100px;" >
						<option value="0">请选择</option>
						<option value="1" {{if $versiontype eq 1}} selected{{/if}}>亚洲</option>
						<option value="2" {{if $versiontype eq 2}} selected{{/if}}>欧美</option>
					</select>
					&nbsp;
					指定日期：
					<select class="selectCss2" name="buy_date" id="buy_date">
						<option value="">请选择</option>
						<option value="30" {{if 30== $buy_date}} selected{{/if}}>30天</option>
						<option value="90" {{if 90== $buy_date}} selected{{/if}}>90天</option>
						<option value="180" {{if 180== $buy_date}} selected{{/if}}>半年</option>
						<option value="365" {{if 365== $buy_date}} selected{{/if}}>一年</option>
					</select>
					-->销量:
					<input type="text" name="sl" id="sl" class="width100" value="{{$sl}}" placeholder="半年内销量" />
					<!--
					<select class="selectCss2" name="sl" id="sl">
						<option value="">请选择</option>
						<option value="10" {{if 10== $sl}} selected{{/if}}>10</option>
						<option value="20" {{if 20== $sl}} selected{{/if}}>20</option>
						<option value="30" {{if 30== $sl}} selected{{/if}}>30</option>
						<option value="40" {{if 40== $sl}} selected{{/if}}>40</option>
						<option value="50" {{if 50== $sl}} selected{{/if}}>50</option>
						<option value="60" {{if 60== $sl}} selected{{/if}}>60</option>
						<option value="70" {{if 70== $sl}} selected{{/if}}>70</option>
						<option value="80" {{if 80== $sl}} selected{{/if}}>80</option>
						<option value="90" {{if 90== $sl}} selected{{/if}}>90</option>
						<option value="100" {{if 100== $sl}} selected{{/if}}>100</option>
					</select>
					-->
					&nbsp;&nbsp;
					采购天数:
					<input type="text" name="buy_days" id="buy_days" class="width100" value="{{$buy_days}}" placeholder="采购天数" />
					采购人员:
					<select name="buyer" id="buyer" class="selection select2_group" style="width:100px;" >
						<option value="0">请选择</option>
						{{foreach from=$userlist item=res key=key}}
						<option value="{{$res}}" {{if $buyer eq $res}} selected{{/if}}>{{$res}}</option>
						{{/foreach}}
					</select>
					<button class="btn btn-primary" id="searchbtn">Search</button>
        <span style="float:right">
       <a href="javascript:void(0)" onClick="purchaseData()" class="stdbtn btn_red"><span>生成采购单</span></a>
       </span>
				</div>
			</form>
			<!--搜索栏结束-->
			<table cellpadding="0" cellspacing="0" id="table2" border="0" class="stdtable" style="table-layout: fixed;">
				<thead>
				<tr>
					<td width="2%"  bgcolor="#FEFFF1">
						<a onClick="allSelect('ppid[]')">全选</a>
					</td>
					<!--
					<td width="6%" bgcolor="#FEFFF1">商品编号</td>
					-->
					<td width="6%" bgcolor="#FEFFF1">
						<a href="/purchase/addFactoryOrder?orderbyxuhao={{$orderbyxuhao}}">商品sku</a><span style="margin-top:15px;">&nbsp;&nbsp;<img src="/fuman/images/{{if $orderbyxuhao=='ASC'}}arrowdown{{else}}arrowup{{/if}}.png"> </span>
					</td>
					<td  width="15%" bgcolor="#FEFFF1">商品名称</td>
					<td  bgcolor="#FEFFF1" >采购数</td>
					<!--
					<td  bgcolor="#FEFFF1">增幅率</td>
					-->
					<td  bgcolor="#FEFFF1">成本价</td>
					<td  bgcolor="#FEFFF1">库位</td>
					<td  bgcolor="#FEFFF1">
						<a href="/purchase/addFactoryOrder?orderbystock={{$orderbystock}}">{{$buy_title}}销量</a><span style="margin-top:15px;">&nbsp;&nbsp;<img src="/fuman/images/{{if $orderbystock=='ASC'}}arrowdown{{else}}arrowup{{/if}}.png"> </span>
					</td>
					<td  bgcolor="#FEFFF1">旺季销量</td>
					<td  bgcolor="#FEFFF1">当月销量</td>
					<td  bgcolor="#FEFFF1" >日均销量</td>
					<td  bgcolor="#FEFFF1" >旺季日均销量</td>
					<td  bgcolor="#FEFFF1" >待发货</td>
					<td  bgcolor="#FEFFF1">在库数</td>
					<td  bgcolor="#FEFFF1" >在途</td>
					<td  bgcolor="#FEFFF1" width="8%" >上架时间</td>
					<!--
					<td  bgcolor="#FEFFF1" >操作</td>
					-->
				</tr>
				</thead>
				<tbody >

				{{foreach from=$goodslist item=li key=key}}
				<tr>
					<td ><input name="ppid[]" type="checkbox" class="none" id="ppid[]" value="{{$li.goods_id}}" /></td>
					<!--
					<td valign="middle" >
						<a href="/product/productlist?other={{$li.goods_sku}}" target="_blank"><font color="#6666FF">{{$li.goods_parent_sku}}</font></a>
					</td>
					-->
					<td valign="middle" >
						<a href="/product/productlist?other={{$li.goods_sku}}" target="_blank"><font color="#6666FF">{{$li.goods_sku}}</font></a>
					</td>
					<td valign="middle">
						{{if $li.g_sale_status==5}}<font color="red"><B>【清仓】</B></font>{{/if}}
						{{if $li.g_sale_status==4}}<font color="Blue"><B>【停产】</B></font>{{/if}}
						{{$li.goods_name}}
						{{if $li.memo}}
							<a href="javascript:void(0)"><img src="/fuman/images/icons/question.png">
								<span id="tip_info">
	                            {{$li.memo}}</span>
							</a>
						{{/if}}
					</td>
					<td valign="middle">
						<input type="text" name="nst[]" id="nst{{$li.goods_id}}" class="width200"  value="{{$li.buy_num}}" style=" padding: 8px 5px; border: 1px solid #ccc;width: 85%;   -moz-border-radius: 2px;
    -webkit-border-radius: 2px;
    border-radius: 2px;
    background: #fcfcfc;
    vertical-align: middle;
    -moz-box-shadow: inset 0 1px 3px #ddd;
    -webkit-box-shadow: inset 0 1px 3px #ddd;
    box-shadow: inset 0 1px 3px #ddd;
    color: #666;">
						<!--
						<input type="hidden" id="hid{{$li.goods_id}}"  name="hid[]" value="{{$li.calcval}}">
						-->
					</td>
					<!--
					<td valign="middle">
						<input type="text" name="rate[]" id="rate{{$li.goods_id}}" class="width200"  value="0.1" style="    padding: 8px 5px; border: 1px solid #ccc;width: 85%;   -moz-border-radius: 2px;
    -webkit-border-radius: 2px;
    border-radius: 2px;
    background: #fcfcfc;
    vertical-align: middle;
    -moz-box-shadow: inset 0 1px 3px #ddd;
    -webkit-box-shadow: inset 0 1px 3px #ddd;
    box-shadow: inset 0 1px 3px #ddd;
    color: #666;">
					</td>
					-->
					<td valign="middle">{{$li.g_costprice}}</td>
					<td class="cz">{{$li.positions}}</td>
					<td class="cz">{{$li.halfyear_num}}</td>
					<td class="cz">{{$li.lastyear_num}}</td>
					<td class="cz">{{$li.curmonth_num}}</td>
					<td valign="middle">{{$li.dailysales}}
					</td>
					<td valign="middle">{{$li.hotdailysales}}
					</td>
					<td valign="middle">{{$li.waitgoods}}
					</td>
					<td class="cz">{{$li.stock}}</td>
					<td class="cz">{{$li.in_transit}}
						{{if $li.in_transit>0}}
							{{if $li.waitday}}
								<br>{{$li.waitday}}
							{{/if}}
						{{/if}}
					</td>
					<td valign="middle">
						{{$li.g_updatetime}}
					</td>
					<!--
					<td class="cz">
			          <span>
			          <a href="/order/ajaxbutton?op=showhistoryOrder&goods_id={{$li.goods_id}}" target="_blank"> 查看订单</a>
			          </span>
					</td>
					-->
				</tr>
				{{/foreach}}
				</tbody>

			</table>
			<div class="page">{{$pageList}} 计{{$total}}条记录<!--，共{{$totalpage}}页--></div>
		</div>
	</div>
	<form class="stdform stdform2" method="post" id="addpurchase" action="/purchase/addpurchase">
		<input type="hidden" value="" id="goods_id_list" name="goods_id_list">
		<input type="hidden" value="" id="goods_nums_list" name="goods_nums_list">
	</form>
	<!-- 修改增幅率-->
	<!-- 模态框（Modal）内容 -->
	<form action="/purchase/updrate" enctype="multipart/form-data" method="post" name="dorecommendattributeform" id="dorecommendattributeform" target="_blank" style="font-size: 14px;font-family: Helvetica, 'Hiragino Sans GB', 'Microsoft Yahei', '微软雅黑', Arial, sans-serif;line-height: 21px;color: #666;">
		<div class="modal" id="dorecommendform" tabindex="-1" role="dialog" aria-labelledby="sexpressform" aria-hidden="true" style="margin-top: 60px;padding-top:60px;">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"
						        aria-hidden="true" onClick="javascript:$('#dorecommendform').hide();">× </button>
						<h4 class="modal-title"><span id="order_mailno" style="font-size:18px;">修改增幅率</span></h4>
					</div>
					<div class="modal-body">
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td align="left" width="100">
									修改增幅率:&nbsp;&nbsp;&nbsp;<input type="text" id="updrate" name="updrate" value="" style="width:400px;" placeholder="请输入增幅率">
								</td>
							</tr>
						</table>
						<div class="modal-footer">
							<button type="button" class="btn btn-default"
							        data-dismiss="modal" style="display:none"> 关闭 </button>
							<input type="hidden" name="goodsids" id="goodsids" value="">
							<button type="button" class="btn btn-primary"  onclick="doRecommend(1)">确认修改</button>
						</div>
					</div>
					<!-- /.modal-content -->
				</div>
				<!-- /.modal-dialog -->
			</div>
		</div>
	</form>
	<div id="goToTop" style="display:none"><a href="javascript:;">TOP</a></div>
</body>
</html>